home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CTextFile 1.1 / TextFileIntf.p < prev   
Encoding:
Text File  |  1994-11-30  |  2.3 KB  |  47 lines  |  [TEXT/PJMM]

  1. unit TextFileIntf;
  2. {CTextFile v1.1 © 1992 by William Studenmund. For distribution info,}
  3. {please see attached About file. This class impliments a TEXT file à la}
  4. {THINK Pascal. Only String reading & writing is supported.}
  5. interface
  6.     uses
  7.         TCL;
  8.     const
  9.         TextBufferSize = 511;
  10.         TextEOLChar = char(13);
  11.         TextSpaceChar = ' ';
  12.     type
  13.         TextBufferT = packed array[0..TextBufferSize] of char;
  14.         CTextFile = object(CDataFile)
  15.                 theBuffer: TextBufferT;
  16.                 BufferLen, BufferPos: integer;
  17.                 OpenForInput, BufferHasData, MoreInFile, HaveAccessed, LastWroteCR, ForceEOL, LongLine: boolean;
  18.                 theLength, LengthLeft: longint;
  19.                 procedure ITextFile;        {Zeroes a bunch of things. The real fun is in the Open procedure}
  20.                 function EOF: boolean;
  21.                 function EOL: boolean;
  22.                 function isLongLine: boolean;        {True if the Read(Ln) routine was kept from finishing the line. See specific routine.}
  23.                 function getLengthLeft: longint;    {How many characters are left in the file THAT HAVEN'T BEEN READ INTO RAM.}
  24.                 procedure Seek (thePlace: longint);    {Pascal way of setting "the Mark." Provided since it's in the Language def.}
  25.                 function Filepos: longint;                        {Pascal way of getting "the Mark"'s position.}
  26.  
  27.                 function Peek: char;
  28.                 procedure Read (var theString: string; HowMuch: integer);
  29.                 procedure ReadLn (var theString: string);
  30.                 procedure Write (var theString: string);        {VAR only for speed}
  31.                 procedure WriteLn (var theString: string);    {VAR only for speed}
  32.  
  33.                 procedure Open (permission: SignedByte);
  34.                 override;    {Note: TextFile only supports exclusive Read or exclusive Write permission.  As it is}
  35.                         {designed to simulate TEXT files, ie one-way streams of information.  I don't want to}
  36.                         {go through and add the complexity of supporting simultaneous read/write ability.  If}
  37.                         {you need that, you don't want this file type. NB: if the file doesn't exist when opening for writing,}
  38.                         {this routine will create it as type 'TEXT' & signature gSignature. If you don't want that,}
  39.                         {create the file before opening}
  40.                 procedure Reset;        {Pascal way of opening file for read-only seuential access}
  41.                 procedure Rewrite;    {Pascal way of opening an empty file for write-only access}
  42.                 procedure OpenForAppending;        {Custom method of opening a file to append to it.}
  43.  
  44.                 procedure ReadBuffer;    {For internal use only}
  45.             end;
  46. implementation
  47. end.